package com.jingdong.dao.productType.impl;

import com.jingdong.dao.productType.ProductTypeThreeDao;
import com.jingdong.model.Product_type_three;
import com.jingdong.utils.MyBatisUtils;
import org.apache.ibatis.session.SqlSession;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public class ProductTypeThreeDaoImpl implements ProductTypeThreeDao {
    @Override
    public List<Product_type_three> threeTypeList(int typeTwoId) {
        try{
            SqlSession sqlSession= MyBatisUtils.getSqlSession();
            List<Product_type_three> type_threeList=sqlSession.selectList("com.jingdong.productThreeTypeModel.list",typeTwoId);
            sqlSession.close();
            return  type_threeList;
        }catch (Exception e){
            e.printStackTrace();
        }
        return null;
    }

    @Override
    public Product_type_three getById(Long id) {
        try{
           SqlSession sqlSession= MyBatisUtils.getSqlSession();
           Product_type_three product_type_three=sqlSession.selectOne("com.jingdong.productThreeTypeModel.getById",id);
           sqlSession.close();
           return product_type_three;
        }catch (Exception e){
            e.printStackTrace();

        }
        return null;
    }

    @Override
    public Product_type_three getTypeByProductTypeId(Long id) {
        try{
            SqlSession sqlSession= MyBatisUtils.getSqlSession();
            Product_type_three product_type_three=sqlSession.selectOne("com.jingdong.productThreeTypeModel.getTypeByProductTypeId",id);
            sqlSession.close();
            return product_type_three;
        }catch (Exception e){
            e.printStackTrace();

        }
        return null;
    }
}
